package com.itheima.es.controller;

import com.itheima.common.es.domain.Goods;
import com.itheima.common.response.ResponseResult;
import com.itheima.es.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

/**
 * @author liqp
 * @version 1.0
 * @date 2021/2/3
 */
@RestController
@RequestMapping("/es")
public class BookController {

    @Autowired
    private BookService bookService;

    @GetMapping
    public ResponseResult<List<Goods>> search(@RequestParam(value = "from", defaultValue = "0") Integer from,
                                              @RequestParam(value = "size", defaultValue = "100") Integer size) throws IOException {
        List<Goods> goodsList = bookService.searchAll(from, size);
        return new ResponseResult<>(goodsList);
    }
}
